package com.yuihong.seekfun;

import android.graphics.Color;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.Random;

public class MainActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener{
    private SeekBar mSeekBar;
    private TextView mTextView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mSeekBar = (SeekBar) findViewById(R.id.seekBar);
        mSeekBar.setOnSeekBarChangeListener(this);

        mTextView = (TextView) findViewById(R.id.textView);
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        Log.d("SeekFun", "here!!");
        mTextView.setTextSize(new Float(seekBar.getProgress()).floatValue());
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        mTextView.setTextColor(Color.rgb(new Random().nextInt(255), new Random().nextInt(255), new Random().nextInt(255)));
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        new AlertDialog.Builder(this).setTitle("松开")
            .setMessage("你松开SeekBar了")
            .show();

    }
}
